const { Model, DataTypes } = require('sequelize')
module.exports = (sequelize, { User, Role }) => {
  class UserRole extends Model {}
  UserRole.init(
    {
      userId: {
        type: DataTypes.STRING(20),
        references: {
          model: 'sys_user',
          key: 'id',
        },
      },
      roleId: {
        type: DataTypes.STRING(20),
        references: {
          model: 'sys_role',
          key: 'id',
        },
      },
    },
    {
      sequelize,
      tableName: 'sys_user_role',
      timestamps: true,
      modelName: 'UserRole',
    }
  )
  return UserRole
}
